package com.hn.y.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hn.y.entity.TbUser;
import com.hn.y.mapper.second.mapper.TbUserMapper;
import com.hn.y.serviceImpl.TbUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jun
 * @since 2021-01-16
 */
@RestController
@RequestMapping("/tbUser")
public class TbUserController {

    @Autowired
    private TbUserServiceImpl tbUserService;

    @GetMapping("/selectOracle")
    public List<TbUser> selectOracle(){
        TbUserMapper baseMapper = tbUserService.getBaseMapper();
        List<TbUser> tbUsers = baseMapper.selectList(null);
        tbUsers.forEach(System.out::println);
        return tbUsers;
    }

    /**
     * 测试mybatis-plus分页插件
     */
    @GetMapping(value = "/selectPage")
    public List<TbUser> selectPage(){
        TbUserMapper baseMapper = tbUserService.getBaseMapper();
        Page<TbUser> page = new Page<>(1,2);
        baseMapper.selectPage(page,null);
        return page.getRecords();
    }

}
